package com.hwadee.backend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hwadee.backend.entity.Apply;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ApplyMapper extends BaseMapper<Apply> {
    // 根据申请人ID查询申请记录
    @Select("SELECT * FROM apply WHERE applicant_id = #{applicantId}")
    List<Apply> selectByApplicantId(@Param("applicantId") int applicantId);
    
    // 根据目标用户ID查询申请记录
    @Select("SELECT * FROM apply WHERE target_user_id = #{targetUserId}")
    List<Apply> selectByTargetUserId(@Param("targetUserId") int targetUserId);
    
    // 查询特定申请人和目标用户的申请记录
    @Select("SELECT * FROM apply WHERE applicant_id = #{applicantId} AND target_user_id = #{targetUserId} LIMIT 1")
    Apply selectByApplicantAndTarget(@Param("applicantId") int applicantId, @Param("targetUserId") int targetUserId);
}